<html>
<head><meta charset="utf-8"><title>Copy type that is not Send · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html">Copy type that is not Send</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="248324828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248324828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248324828">(Aug 04 2021 at 08:51)</a>:</h4>
<p>Is there a Copy type that is not Send ? (i.e. T: Copy + !Send) ?</p>



<a name="248325254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248325254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248325254">(Aug 04 2021 at 08:56)</a>:</h4>
<p>Yes there is, <code>RefCell</code>.</p>



<a name="248325312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248325312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Giacomo Stevanato <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248325312">(Aug 04 2021 at 08:56)</a>:</h4>
<p><code>*mut T</code>, <code>*const T</code> and <code>NonNull&lt;T&gt;</code> are <code>Copy</code> but not <code>Send</code> nor <code>Sync</code></p>



<a name="248325351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248325351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Giacomo Stevanato <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248325351">(Aug 04 2021 at 08:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248325254">said</a>:</p>
<blockquote>
<p>Yes there is, <code>RefCell</code>.</p>
</blockquote>
<p><code>RefCell</code> is <code>Send</code> but not <code>Sync</code></p>



<a name="248355626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248355626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248355626">(Aug 04 2021 at 14:16)</a>:</h4>
<p>Why aren't <code>*mut T</code>, <code>*const T</code> and <code>NonNull&lt;T&gt;</code> <code>Send</code> ?</p>
<p>They can be sent across threads without issues, or I have misunderstood something fundamental about rust.</p>



<a name="248355717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248355717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248355717">(Aug 04 2021 at 14:16)</a>:</h4>
<p>Yeah, it is _sound_ to send <code>*mut T</code> across threads - as in: it is impossible to cause UB by doing that _without using <code>unsafe</code> code_. This is so weird.</p>
<p>Are there any <code>T: Copy + !Send</code> types, that can't be <code>Send</code> for _soundness_ ?</p>



<a name="248356299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248356299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Smittyvb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248356299">(Aug 04 2021 at 14:21)</a>:</h4>
<p>It's more of a lint against doing that: <a href="https://doc.rust-lang.org/nomicon/send-and-sync.html#send-and-sync">https://doc.rust-lang.org/nomicon/send-and-sync.html#send-and-sync</a></p>



<a name="248358182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248358182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248358182">(Aug 04 2021 at 14:33)</a>:</h4>
<p>You can implement those lints in clippy or as a warning, but it makes no sense to have to create a wrapper type to just make a raw pointer Send. </p>
<p>I just fixed this in my Rust fork.</p>
<p>Looking at the github issue history, it seems that this was changed without going through the RFC process.</p>



<a name="248358502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248358502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248358502">(Aug 04 2021 at 14:35)</a>:</h4>
<blockquote>
<p>You can implement those lints in clippy or as a warning, but it makes no sense to have to create a wrapper type to just make a raw pointer Send. </p>
<p>I just fixed this in my Rust fork.</p>
<p>Looking at the github issue history, it seems that this was changed without going through the RFC process.</p>
</blockquote>
<p>It allows stably writing wrappers like Rc that are not Send as well</p>



<a name="248358673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248358673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248358673">(Aug 04 2021 at 14:37)</a>:</h4>
<p>Users can't unimplement auto traits, so if *mut T was Send for any T, then there isn't a way to opt-out directly for Rc&lt;T&gt;, or any kind of thread-local handle types.</p>



<a name="248358945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248358945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248358945">(Aug 04 2021 at 14:38)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/21689">https://github.com/rust-lang/rust/pull/21689</a> made this not-send and not-sync without any discussion.</p>



<a name="248359048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359048">(Aug 04 2021 at 14:39)</a>:</h4>
<blockquote>
<p>Users can't unimplement auto traits, so if *mut T was Send for any T, then there isn't a way to opt-out directly for Rc&lt;T&gt;, or any kind of thread-local handle types.</p>
</blockquote>
<p>There are many ways to solve that problem. Making raw pointers !Send and !Sync is a very poor solution.</p>



<a name="248359214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359214">(Aug 04 2021 at 14:40)</a>:</h4>
<p>None that can be done as easily, and it's also a foot gun if you have to explicitly opt-in to being <code>!Send + !Sync</code>.</p>



<a name="248359306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359306">(Aug 04 2021 at 14:40)</a>:</h4>
<p>As easy as <code>NonSendPtr&lt;T&gt;</code></p>



<a name="248359411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359411">(Aug 04 2021 at 14:41)</a>:</h4>
<p>It makes no sense to pessimize the use of raw pointers _everywhere_ to make one single use case - putting them inside structs that _sometimes_ should not be send - simpler.</p>



<a name="248359538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359538">(Aug 04 2021 at 14:42)</a>:</h4>
<p>If I write <code>struct Slice&lt;T&gt;(*mut T, usize)</code> I want <code>Slice</code> to be <code>Send</code> and <code>Sync</code>.</p>



<a name="248359575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359575">(Aug 04 2021 at 14:42)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">extern</span><span class="s">"C"</span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">some_thread_unsafe_api_constructor</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="n">c_void</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">some_thread_unsafe_api</span><span class="p">(</span><span class="n">x</span>: <span class="o">*</span><span class="n">c_void</span><span class="p">)</span><span class="w"> </span>-&gt;  <span class="kt">u32</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">SafeWrapper</span><span class="p">(</span><span class="o">*</span><span class="k">mut</span><span class="w"> </span><span class="n">c_void</span><span class="p">);</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">SafeWrapper</span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">new</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">{</span><span class="w"></span>
<span class="w">         </span><span class="bp">Self</span><span class="p">(</span><span class="k">unsafe</span><span class="p">{</span><span class="n">some_thread_unsafe_api_constructor</span><span class="p">()})</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">some_api</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">u32</span><span class="p">{</span><span class="w"></span>
<span class="w">         </span><span class="k">unsafe</span><span class="p">{</span><span class="n">some_thread_unsafe_api</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="mi">0</span><span class="p">)}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="c1">// Oops, we're Send+Sync</span>
</code></pre></div>



<a name="248359664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359664">(Aug 04 2021 at 14:43)</a>:</h4>
<p>so ? the <code>unsafe</code> there is at fault</p>



<a name="248359700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359700">(Aug 04 2021 at 14:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248359538">said</a>:</p>
<blockquote>
<p>If I write <code>struct Slice&lt;T&gt;(*mut T, usize)</code> I want <code>Slice</code> to be <code>Send</code> and <code>Sync</code>.</p>
</blockquote>
<p>In what cases for <code>T</code> though? There is not one correct answer when raw pointers are involved.</p>



<a name="248359791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359791">(Aug 04 2021 at 14:44)</a>:</h4>
<p>For all cases. When I use <code>Slice</code> I need to use <code>unsafe</code>, and I can use <code>atomics</code> to make those uses safe.</p>



<a name="248359876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359876">(Aug 04 2021 at 14:44)</a>:</h4>
<p>To me, it only makes sense to ban this if allowing it is unsound. </p>
<p>But allowing it is sound.</p>



<a name="248359928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359928">(Aug 04 2021 at 14:45)</a>:</h4>
<p>The argument "but if then people use <code>unsafe</code> they can shoot themselves in the foot" is pretty moot</p>



<a name="248359945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359945">(Aug 04 2021 at 14:45)</a>:</h4>
<p>Either don't use <code>unsafe</code>, or use it properly</p>



<a name="248359977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248359977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248359977">(Aug 04 2021 at 14:45)</a>:</h4>
<p>That rationale can be applied to <code>unsafe</code> as a whole</p>



<a name="248360007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360007">(Aug 04 2021 at 14:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248359791">said</a>:</p>
<blockquote>
<p>For all cases. When I use <code>Slice</code> I need to use <code>unsafe</code>, and I can use <code>atomics</code> to make those uses safe.</p>
</blockquote>
<p>That's your case and you can express this.<br>
What about a case where <code>Slice&lt;T&gt;</code> is Send iff T: Send, and Sync iff T: Sync</p>



<a name="248360069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360069">(Aug 04 2021 at 14:46)</a>:</h4>
<p>Then the <code>impls</code> can propagate this.</p>



<a name="248360155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360155">(Aug 04 2021 at 14:46)</a>:</h4>
<p>I can provie a <code>Slice&lt;T&gt;::read</code> even if <code>T: !Send</code> though</p>



<a name="248360208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360208">(Aug 04 2021 at 14:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248359945">said</a>:</p>
<blockquote>
<p>Either don't use <code>unsafe</code>, or use it properly</p>
</blockquote>
<p>The point of unsafe rust is to make it easier to use properly. As it stands, unsafe rust is still easier to get right than C or C++. Saying that raw pointers by default are always <code>Send+Sync</code> is a great way to hand people footguns.</p>



<a name="248360395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360395">(Aug 04 2021 at 14:48)</a>:</h4>
<p>Learning <code>unsafe</code> is hard. Saying that raw pointers are not <code>Send+Sync</code> suggests that making them <code>Send+Sync</code> is _unsound_. Which it isn't. Which makes the language inconsistent and this particular part of the language harder to learn and use for everybody.</p>



<a name="248360469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360469">(Aug 04 2021 at 14:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248360395">said</a>:</p>
<blockquote>
<p>Learning <code>unsafe</code> is hard. Saying that raw pointers are not <code>Send+Sync</code> suggests that making them <code>Send+Sync</code> is _unsound_. Which it isn't. Which makes the language inconsistent and this particular part of the language harder to learn and use for everybody.</p>
</blockquote>
<p>It's not unsound on it's face, but making them so makes a very large amount of code unsound.</p>



<a name="248360532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360532">(Aug 04 2021 at 14:49)</a>:</h4>
<p>And a lot of that code exists, so it definately won't be changed now.</p>



<a name="248360567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360567">(Aug 04 2021 at 14:49)</a>:</h4>
<p>Right, which is why I've only fixed this in my fork.</p>



<a name="248360628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360628">(Aug 04 2021 at 14:49)</a>:</h4>
<p>Fixing this would requre a new edition.</p>



<a name="248360708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360708">(Aug 04 2021 at 14:50)</a>:</h4>
<p>(if this is fixable at all)</p>



<a name="248360880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248360880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248360880">(Aug 04 2021 at 14:51)</a>:</h4>
<p>Fixing it can't be done currently, since it's a stdlib breaking change. Even if it could though, I highly doubt it would. As I say, <code>unsafe</code> rust gives you the tools to shoot yourself in the foot, but it doesn't shove them in your face. 9 times out of 10, using a totally Send+Sync raw pointer is going to be wrong.</p>



<a name="248361291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361291">(Aug 04 2021 at 14:54)</a>:</h4>
<p>More like 1 out of 10</p>



<a name="248361359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361359">(Aug 04 2021 at 14:54)</a>:</h4>
<p>From the nomicon:</p>
<blockquote>
<p>However it's important that they aren't thread-safe to prevent types that contain them from being automatically marked as thread-safe. These types have non-trivial untracked ownership, and it's unlikely that their author was necessarily thinking hard about thread safety.</p>
</blockquote>
<p>Put another way, if  your <code>Slice</code> type, which contains raw pointers, is <code>Send</code> and <code>Sync</code>, it is because the compiler forced you to think about it and you made sure that it actually was <code>Send + Sync</code></p>



<a name="248361372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361372">(Aug 04 2021 at 14:54)</a>:</h4>
<p>Unless 90% of your time is spent writing type declarations, and only 10% of the time is spent actually writing programs that use them.</p>



<a name="248361456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361456">(Aug 04 2021 at 14:55)</a>:</h4>
<p>The compiler did not force me to think about it. I did it on my own, because it was obvious that it was correct.</p>



<a name="248361480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361480">(Aug 04 2021 at 14:55)</a>:</h4>
<p>The standard library implementation forced me to find a workaround.</p>



<a name="248361508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361508">(Aug 04 2021 at 14:55)</a>:</h4>
<p>And to change my APIs from <code>*mut [T]</code> to <code>Slice</code> for no reason</p>



<a name="248361572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361572">(Aug 04 2021 at 14:56)</a>:</h4>
<p>No, my figure is correct. If <code>*mut T</code> was unconditionally <code>Send+Sync</code>, this would be wrong for:</p>
<ul>
<li><code>Box</code></li>
<li><code>Rc</code></li>
<li><code>Arc</code></li>
<li><code>Vec</code></li>
<li><code>BTreeMap</code></li>
<li><code>HashMap</code></li>
<li><code>String</code></li>
<li>etc.</li>
<li>Any user implementation of the above</li>
</ul>



<a name="248361618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361618">(Aug 04 2021 at 14:56)</a>:</h4>
<p>So 90% of the time you spent programming is spent in <strong>creating</strong> those types ?</p>



<a name="248361699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361699">(Aug 04 2021 at 14:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248361508">said</a>:</p>
<blockquote>
<p>And to change my APIs from <code>*mut [T]</code> to <code>Slice</code> for no reason</p>
</blockquote>
<p>Raw pointers are difficult to use statically because they are difficult to use properly. Very little code should be using raw pointers except within some safe wrapper thereof</p>



<a name="248361706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361706">(Aug 04 2021 at 14:57)</a>:</h4>
<p>Because 99.999% of the time i spent is spent in <strong>using</strong> them. The time it takes me to create them is close to 0. So I spend most time just _using_ raw pointers, and almost 0 time creating wrappers for them.</p>



<a name="248361888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361888">(Aug 04 2021 at 14:58)</a>:</h4>
<p>I give up. Have fun in your throne. </p>
<p>You know what's best for me.</p>



<a name="248361993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248361993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248361993">(Aug 04 2021 at 14:59)</a>:</h4>
<p>Which is funny, since you say that you never use raw pointers, but simultaneously say that this footgun is super important, because you spent all your time writing code that would break without it.</p>



<a name="248362081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362081">(Aug 04 2021 at 14:59)</a>:</h4>
<p>Fact is: sending a raw pointer to another thread is sound. </p>
<p>The fact that you are too scared to use raw pointers is a bad argument for not making them Send.</p>



<a name="248362341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362341">(Aug 04 2021 at 15:01)</a>:</h4>
<p>The argument that "it's too late" is probably true, but back then this was sweeped in without an RFC. There is zero discussion available about why this decision was made. And all points that, like all the other half-baked "lints" in the language (AssertUnwindSafe), this was a bad idea.</p>



<a name="248362356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362356">(Aug 04 2021 at 15:01)</a>:</h4>
<p>I almost never use raw pointers outside of wrappers like those types. I use them internally in some places, but for very short lengths of code, where I can justify every single use by some locally satisfied invariant. I would think twice before making them a public api, and I have run accross the issue of <code>*mut (): !Sync</code> and needing a wrapper exclusively for that purpose, exactly once.</p>



<a name="248362461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362461">(Aug 04 2021 at 15:01)</a>:</h4>
<p>Thank you for your anecdotal evidence. As a king, therefore, no other programmers facing other issues exist.</p>



<a name="248362618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362618">(Aug 04 2021 at 15:03)</a>:</h4>
<p>I face this enough in low-level programming to maintain my own rustc fork, that now fixes this for raw pointers. For the std lib types using it, I can just add negative impls: <code>impl&lt;T: ?Sized&gt; !Send for RawVec&lt;T&gt; {}</code>.</p>



<a name="248362735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362735">(Aug 04 2021 at 15:03)</a>:</h4>
<p>What about user-defined types? Now any library that uses raw pointers and relies on the negative impls for soundness cannot be used on that fork.</p>



<a name="248362778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362778">(Aug 04 2021 at 15:04)</a>:</h4>
<p>Yep</p>



<a name="248362888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362888">(Aug 04 2021 at 15:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248362341">said</a>:</p>
<blockquote>
<p>The argument that "it's too late" is probably true, but back then this was sweeped in without an RFC. There is zero discussion available about why this decision was made. And all points that, like all the other half-baked "lints" in the language (AssertUnwindSafe), this was a bad idea.</p>
</blockquote>
<p>When was this decision made? Can you point me to the issue? I'm interested by the context <span aria-label="big smile" class="emoji emoji-1f604" role="img" title="big smile">:big_smile:</span></p>



<a name="248362933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248362933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248362933">(Aug 04 2021 at 15:05)</a>:</h4>
<p>It was implemented in this PR: <a href="https://github.com/rust-lang/rust/pull/21689">https://github.com/rust-lang/rust/pull/21689</a></p>



<a name="248363033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248363033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248363033">(Aug 04 2021 at 15:05)</a>:</h4>
<p>Couple of months before 1.0 release</p>



<a name="248363225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248363225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248363225">(Aug 04 2021 at 15:07)</a>:</h4>
<p>There is an RFC here: <a href="https://github.com/rust-lang/rfcs/pull/127/files">https://github.com/rust-lang/rfcs/pull/127/files</a></p>



<a name="248363542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248363542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248363542">(Aug 04 2021 at 15:09)</a>:</h4>
<p>Looks like raw pointers didn't implement <code>Send</code> and <code>Sync</code> even before <a href="https://github.com/rust-lang/rust/issues/21689">#21689</a></p>



<a name="248363917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248363917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248363917">(Aug 04 2021 at 15:12)</a>:</h4>
<p>Im pretty sure before you could decide, i.e., you could just add your own <code>unsafe impl&lt;T&gt; Send for *mut T {}</code> anywhere.</p>



<a name="248363981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248363981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248363981">(Aug 04 2021 at 15:13)</a>:</h4>
<p>I don't believe raw pointers are fundamental, so I would assume not.</p>



<a name="248364007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364007">(Aug 04 2021 at 15:13)</a>:</h4>
<p>There was no fundamental back then.</p>



<a name="248364140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364140">(Aug 04 2021 at 15:14)</a>:</h4>
<p>When you want some raw pointer to be Send/Sync (sometimes useful in FFI), common Rust usage is to wrap them in a type that does it for your use case, that way you can document invariants and sometimes even use assertions to ensure said invariants are not broken</p>



<a name="248364169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364169">(Aug 04 2021 at 15:14)</a>:</h4>
<blockquote>
<p>If *mut T was unconditionally Send+Sync, this would be wrong for:</p>
<p>Box<br>
   Rc<br>
   Arc<br>
   Vec</p>
</blockquote>
<p>Notice that if <code>*mut T</code> was unconditionally <code>Send</code>, this would be right for <code>Box</code>, <code>Arc</code>, <code>Vec</code>.</p>



<a name="248364190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364190">(Aug 04 2021 at 15:14)</a>:</h4>
<p>Maintaining a whole fork of rustc just for that seems a little much</p>



<a name="248364235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364235">(Aug 04 2021 at 15:14)</a>:</h4>
<p>The attribute didn't exist, but I assume the coherence rules did, at some level, and <code>*mut T</code> is treated as a foreign type, so you couldn't implement the foreign Send trait for the foreign <code>*mut T</code> type</p>



<a name="248364267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364267">(Aug 04 2021 at 15:15)</a>:</h4>
<blockquote>
<p>When you want some raw pointer to be Send/Sync (sometimes useful in FFI), common Rust usage is to wrap them in a type that does it for your use case, that way you can document invariants and sometimes even use assertions to ensure said invariants are not broken</p>
</blockquote>
<p>I can't coerce <code>&amp;mut [T]</code> to <code>Slice&lt;T&gt;</code> easily, so this solution has a huge economic drawback for most of the code that I write.</p>



<a name="248364329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364329">(Aug 04 2021 at 15:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248364169">said</a>:</p>
<blockquote>
<blockquote>
<p>If *mut T was unconditionally Send+Sync, this would be wrong for:</p>
<p>Box<br>
   Rc<br>
   Arc<br>
   Vec</p>
</blockquote>
<p>Notice that if <code>*mut T</code> was unconditionally <code>Send</code>, this would be right for <code>Box</code>, <code>Arc</code>, <code>Vec</code>.</p>
</blockquote>
<p>No it wouldn't still because then <code>Box&lt;T&gt;: Send</code>, even if <code>T: !Send</code>, by default</p>



<a name="248364497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364497">(Aug 04 2021 at 15:16)</a>:</h4>
<p>Right, all these types would need to opt in to conditional negative impls.</p>



<a name="248364529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364529">(Aug 04 2021 at 15:16)</a>:</h4>
<blockquote>
<p>I can't coerce <code>&amp;mut [T]</code> to <code>Slice&lt;T&gt;</code> easily, so this solution has a huge economic drawback for most of the code that I write.</p>
</blockquote>
<p>I think the layout are compatibles so transmute should be ok ? With a helper func/macro, it may be a little heavy at compile time but should not have any runtime cost</p>



<a name="248364597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364597">(Aug 04 2021 at 15:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248364497">said</a>:</p>
<blockquote>
<p>Right, all these types would need to opt in to conditional negative impls.</p>
</blockquote>
<p>And what about a user-defined <code>Box</code> type? Same issue.</p>



<a name="248364624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Smittyvb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364624">(Aug 04 2021 at 15:17)</a>:</h4>
<p>You could probably just use a macro to simplify the making of structs with raw pointers that are <code>Send</code>/<code>Sync</code></p>



<a name="248364736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364736">(Aug 04 2021 at 15:18)</a>:</h4>
<p>I'm complaining about the API overhead, the fact that I can't just pass a <code>&amp;mut [T]</code> where a slice is expected.</p>
<blockquote>
<p>And what about a user-defined Box type? Same issue.</p>
</blockquote>
<p>If <code>Box</code> was using raw pointers, sure. If its using <code>NonNull</code>, and that does it right, then it wouldn't have the same issue.</p>



<a name="248364864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364864">(Aug 04 2021 at 15:19)</a>:</h4>
<p><code>NonNull&lt;T&gt;</code> doesn't have a correct default either.</p>



<a name="248364905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364905">(Aug 04 2021 at 15:19)</a>:</h4>
<blockquote>
<p>NonNull&lt;T&gt; doesn't have a correct default either.</p>
</blockquote>
<p>Not yet. In my fork it does.</p>
<blockquote>
<p>You could probably just use a macro to simplify the making of structs with raw pointers that are Send/Sync</p>
</blockquote>
<p>I want to use <code>*mut [T]</code> in my APIs, and I want to be able to call them with <code>foo(x : &amp;mut [T])</code> and have that to just work.</p>



<a name="248364952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364952">(Aug 04 2021 at 15:19)</a>:</h4>
<p>Having to use macros, wrappers, different types, etc. is something i'm not willing to put up with when for me the fix is simple.</p>



<a name="248364959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248364959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248364959">(Aug 04 2021 at 15:19)</a>:</h4>
<p>For api, wouldn’t making your functions generic over AsRef or Into be enough ?</p>



<a name="248365025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365025">(Aug 04 2021 at 15:20)</a>:</h4>
<p>I wouldn’t call a fork of rustc simple</p>



<a name="248365082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365082">(Aug 04 2021 at 15:20)</a>:</h4>
<p>A fork is trivial. Making the function generic, isn't. I don't want generic functions, I want functions.</p>



<a name="248365139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365139">(Aug 04 2021 at 15:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248364905">said</a>:</p>
<blockquote>
<blockquote>
<p>NonNull&lt;T&gt; doesn't have a correct default either.</p>
</blockquote>
<p>Not yet. In my fork it does.</p>
</blockquote>
<p>What I mean is, code using <code>NonNull&lt;T&gt;</code> has the exact same issues as using <code>*mut T</code> directly, in that there is no singular correct default for the type. <code>NonNull&lt;T&gt;</code> can represent an owning, mutably borrowing, immutably borrowing, shared mutably borrowing, etc. pointer just as much as a raw pointer can.</p>



<a name="248365177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365177">(Aug 04 2021 at 15:21)</a>:</h4>
<blockquote>
<p>I want to use <code>*mut [T]</code> in my APIs, and I want to be able to call them with <code>foo(x : &amp;mut [T])</code> and have that to just work.</p>
</blockquote>
<p>Without null checking ? That may work most of the time but have fun debugging any error due to UB on that</p>



<a name="248365192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365192">(Aug 04 2021 at 15:21)</a>:</h4>
<p>Also these are not "refs", these are raw pointers for a reason, so treating them as references inside the function would be UB.</p>



<a name="248365215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365215">(Aug 04 2021 at 15:21)</a>:</h4>
<p>A &amp;mut T is never null, no need to check that.</p>



<a name="248365314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365314">(Aug 04 2021 at 15:22)</a>:</h4>
<p>I understood your sentence as « passing a pointer as a reference »</p>



<a name="248365333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365333">(Aug 04 2021 at 15:22)</a>:</h4>
<p>passing a reference where a pointer is expected</p>



<a name="248365364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365364">(Aug 04 2021 at 15:22)</a>:</h4>
<p><code>foo(x: &amp;mut [T])</code> is a function call with type ascription</p>



<a name="248365398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365398">(Aug 04 2021 at 15:23)</a>:</h4>
<p>the signature of <code>foo</code> would be <code>fn foo(x: *mut [T])</code></p>



<a name="248365445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365445">(Aug 04 2021 at 15:23)</a>:</h4>
<p>going from <code>&amp;mut [T]</code> to <code>*mut [T]</code> is ok, and works automatically</p>



<a name="248365473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365473">(Aug 04 2021 at 15:23)</a>:</h4>
<p>the other way around isn't always sound</p>



<a name="248365563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365563">(Aug 04 2021 at 15:24)</a>:</h4>
<blockquote>
<p>A fork is trivial. Making the function generic, isn't. I don't want generic functions, I want functions.</p>
</blockquote>
<p>I disagree on that, but why do you want no generics ?</p>



<a name="248365596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365596">(Aug 04 2021 at 15:24)</a>:</h4>
<p>Are you doing FII ?</p>



<a name="248365603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365603">(Aug 04 2021 at 15:24)</a>:</h4>
<p>Because it makes no sense to make functions generic just for this.</p>



<a name="248365680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365680">(Aug 04 2021 at 15:25)</a>:</h4>
<p>But generics are made especially for this type of problems, especially with traits</p>



<a name="248365753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365753">(Aug 04 2021 at 15:25)</a>:</h4>
<p>Abstracting over common behavior of different types</p>



<a name="248365768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365768">(Aug 04 2021 at 15:25)</a>:</h4>
<p>Generics are made for when you need a function to be generic, the function <code>foo</code> above doesn't have to be.</p>



<a name="248365847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365847">(Aug 04 2021 at 15:26)</a>:</h4>
<p>You can misuse generics for this, but I don't want to do that.</p>



<a name="248365874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365874">(Aug 04 2021 at 15:26)</a>:</h4>
<p>The consequence is slower compile-times, larger binary sizes, etc.</p>



<a name="248365899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365899">(Aug 04 2021 at 15:26)</a>:</h4>
<p>Things I'm not willing to trade-off when the fix is simple.</p>



<a name="248365900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365900">(Aug 04 2021 at 15:26)</a>:</h4>
<p>Specifically this no, but the Slice/[T] problem earlier is just that, hidden common behavior</p>



<a name="248365942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248365942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248365942">(Aug 04 2021 at 15:27)</a>:</h4>
<p>No, the problem is lack of user defined coercions.</p>



<a name="248366007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366007">(Aug 04 2021 at 15:27)</a>:</h4>
<p>There are many ways to work around that. Making all your API generic is just one way with few pros and many cons.</p>



<a name="248366192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366192">(Aug 04 2021 at 15:29)</a>:</h4>
<blockquote>
<p>What I mean is, code using NonNull&lt;T&gt; has the exact same issues as using *mut T directly, in that there is no singular correct default for the type. NonNull&lt;T&gt; can represent an owning, mutably borrowing, immutably borrowing, shared mutably borrowing, etc. pointer just as much as a raw pointer can.</p>
</blockquote>
<p>A raw pointer isn't owning, not per se. You can build a Box type on top, and give it owning semantics if you want, but if some C API returns you an opaque raw pointer, it can be anything.</p>



<a name="248366234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366234">(Aug 04 2021 at 15:29)</a>:</h4>
<p>Passing these pointers across threads is safe and sound.</p>



<a name="248366256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366256">(Aug 04 2021 at 15:29)</a>:</h4>
<p>Giving extra meaning to these pointers, like ownership or borrowing, is the job of higher level types.</p>



<a name="248366286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366286">(Aug 04 2021 at 15:29)</a>:</h4>
<p>Deref, AsRef, Into, TryInto are all user defined coercions that exist today and would probably work for you, at the cost of a few seconds of compile time. Forking rustc and breaking pretty much every crate and the standard library by making pointers send and sync seems like a lot of work compared to that, especially if other people come to work on your project and they have to relearn the rules</p>



<a name="248366364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366364">(Aug 04 2021 at 15:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248365899">said</a>:</p>
<blockquote>
<p>Things I'm not willing to trade-off when the fix is simple.</p>
</blockquote>
<p>As mentioned, maintaining a fork of rust the language is not simple. For starters, you are no longer writing rust, you are writing hannahE2-rust, with different global invariants and requirements, and now you have to audit all of your unsafe code within the context of your own fork, including unsafe code you perhaps didn't write.</p>



<a name="248366418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366418">(Aug 04 2021 at 15:30)</a>:</h4>
<p>For me its simple.</p>



<a name="248366627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366627">(Aug 04 2021 at 15:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248366192">said</a>:</p>
<blockquote>
<blockquote>
<p>What I mean is, code using NonNull&lt;T&gt; has the exact same issues as using *mut T directly, in that there is no singular correct default for the type. NonNull&lt;T&gt; can represent an owning, mutably borrowing, immutably borrowing, shared mutably borrowing, etc. pointer just as much as a raw pointer can.</p>
</blockquote>
<p>A raw pointer isn't owning, not per se. You can build a Box type on top, and give it owning semantics if you want, but if some C API returns you an opaque raw pointer, it can be anything.</p>
</blockquote>
<p>And that anything can including being owning. I use raw pointers a ton in C to represent an owned type. If you treated it as a shared type, you'd be incorrect and cause soundness issues. And in some cases, it's not sound to transfer to a different thread because the thing it's owning isn't sound to use on a different thread. Raw pointers don't communicate what they are (owning, borrowing, shared owning), but that doesn't mean it's none of those things, it means they can be any of those things.</p>



<a name="248366786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366786">(Aug 04 2021 at 15:33)</a>:</h4>
<p>Thus, the default for  them is the one that is the most correct, and the most noisy when it's incorrect.</p>



<a name="248366887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366887">(Aug 04 2021 at 15:34)</a>:</h4>
<blockquote>
<p>you'd be incorrect and cause soundness issues. </p>
</blockquote>
<p>No, this _can't_ cause a soundness issue without an unsafe block somewhere.</p>



<a name="248366912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248366912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248366912">(Aug 04 2021 at 15:34)</a>:</h4>
<p>And its that <code>unsafe</code> block which cause the soundness bug, not this.</p>



<a name="248367440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248367440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248367440">(Aug 04 2021 at 15:39)</a>:</h4>
<p>You can write a <code>Unique</code>, <code>Shared</code>, etc. wrapper on top of raw pointers to give them more meaning. </p>
<p>But sending a raw pointer to another thread is ok. Using it might always, never, or sometimes be ok, depending on runtime state. Those conditions should be checked before the <code>unsafe</code> block.</p>



<a name="248367459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248367459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248367459">(Aug 04 2021 at 15:39)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248366256">said</a>:</p>
<blockquote>
<p>Giving extra meaning to these pointers, like ownership or borrowing, is the job of higher level types.</p>
</blockquote>
<p>As an aside, this would be an argument against using raw pointers extenrally.</p>



<a name="248367522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248367522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248367522">(Aug 04 2021 at 15:40)</a>:</h4>
<p>Your argument could be applied to <code>NonNull</code> as well, i.e., if you ever use a raw pointer, it must not be null, therefore we only need <code>NonNull</code>, and we don't need raw pointers that can be null.</p>



<a name="248367597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248367597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248367597">(Aug 04 2021 at 15:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248367440">said</a>:</p>
<blockquote>
<p>You can write a <code>Unique</code>, <code>Shared</code>, etc. wrapper on top of raw pointers to give them more meaning. </p>
<p>But sending a raw pointer to another thread is ok. Using it might always, never, or sometimes be ok, depending on runtime state. Those conditions should be checked before the <code>unsafe</code> block.</p>
</blockquote>
<p>Some requirements can be hard to check and are easier to just through invariants.</p>



<a name="248367701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248367701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248367701">(Aug 04 2021 at 15:41)</a>:</h4>
<p>The fact remains that it is still valuable to have pointers that are null or non-null dynamically, depending on context, and in the same way it is useful to have raw pointers, that have different ownership / borrowing semantics, depending on context, and in both cases it is useful to send these types across threads, and doing so is correct and sound.</p>



<a name="248367821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248367821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248367821">(Aug 04 2021 at 15:42)</a>:</h4>
<p>Checking what you have is a dynamic check that you have to do before using <code>unsafe</code>, otherwise you can get UB. </p>
<p>You can avoid those checks by using wrappers that encode them statically, but the fact that you can write those wrappers does not mean that they solve all problems.</p>



<a name="248367876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248367876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248367876">(Aug 04 2021 at 15:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248367701">said</a>:</p>
<blockquote>
<p>The fact remains that it is still valuable to have pointers that are null or non-null dynamically, depending on context, and in the same way it is useful to have raw pointers, that have different ownership / borrowing semantics, depending on context, and in both cases it is useful to send these types across threads, and doing so is correct and sound.</p>
</blockquote>
<p>That is true (though <code>Option&lt;NonNull&lt;T&gt;&gt;</code> expresses this much better than raw pointers). <br>
My argument is that apis that aren't low-level apis should typically not publically use pointers.</p>



<a name="248368075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248368075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248368075">(Aug 04 2021 at 15:44)</a>:</h4>
<p>I agree with your argument. </p>
<p>I think people that use raw pointers should know better, and have to deal with unsafe anyways.</p>
<p>Adding hurdles to them that solve no problems makes no sense, particularly when doing so makes the notion of soundness in rust more complicated.</p>



<a name="248368154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248368154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248368154">(Aug 04 2021 at 15:44)</a>:</h4>
<p>And that if apis are not publically using pointers, there is little benefit to having them incorrectly default to being universally Send+Sync, and unwittingly opting a huge amount of unsafe code using them into that default which is more likely than not invalid for their type.</p>



<a name="248368195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248368195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248368195">(Aug 04 2021 at 15:44)</a>:</h4>
<p>Is it sound to send a raw pointer in Rust? Yes, well, no, well depends: some code assumes that they are not Send for soundness, and rely on that, but the raw pointers themselves are sound to send, so just write a wrapper.</p>



<a name="248368598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248368598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248368598">(Aug 04 2021 at 15:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="409057">hannahE2</span> <a href="#narrow/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send/near/248368195">said</a>:</p>
<blockquote>
<p>Is it sound to send a raw pointer in Rust? Yes, well, no, well depends: some code assumes that they are not Send for soundness, and rely on that, but the raw pointers themselves are sound to send, so just write a wrapper.</p>
</blockquote>
<p>Users cannot opt-out as is (and negative impls have way too many open questions to consider stabilizing at this time IIRC). Even if they could, the fact that it's <code>!Send+!Sync</code> is very noisy when you try to (mis)use them, which makes it strictly better than having them default to <code>Send+Sync</code> which would silently break. It's fairly easy to misjustify things, especially surrounding thread safety, and there is no reason that a low-level piece of the rust language that should only ever be used internally should contribute to that.</p>



<a name="248368673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248368673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248368673">(Aug 04 2021 at 15:48)</a>:</h4>
<p>(Also related, raw pointers are the only way to opt out of Send without having to embed a lifetime in your type)</p>



<a name="248369141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248369141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248369141">(Aug 04 2021 at 15:53)</a>:</h4>
<p>Are there any other <code>Copy + !Send</code> types ? That's really weird the more I think about it.</p>



<a name="248369539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248369539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248369539">(Aug 04 2021 at 15:56)</a>:</h4>
<p>Sure, <code>&amp;T</code> where <code>T: !Sync</code>, but that's also <code>!Sync</code>.<br>
In fact, any type that is <code>Sync+Copy</code> must logically be <code>Send</code>.</p>



<a name="248370012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248370012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hannahE2 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248370012">(Aug 04 2021 at 16:00)</a>:</h4>
<p>Right, so <code>&amp;T</code> is Copy, but if <code>T</code> is not <code>Sync</code> then <code>&amp;T</code> is not  <code>Send</code></p>



<a name="248370155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248370155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248370155">(Aug 04 2021 at 16:01)</a>:</h4>
<p>Yup, since, by definition <code>T: Sync &lt;=&gt; &amp;T: Send</code></p>



<a name="248380003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248380003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matt1992 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248380003">(Aug 04 2021 at 17:18)</a>:</h4>
<p><code>&amp;Cell&lt;T&gt;</code> is <code>Copy + !Send</code><br>
<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=9276550dbef4eabfb71948a1fdb88d78">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=9276550dbef4eabfb71948a1fdb88d78</a></p>
<div class="codehilite"><pre><span></span><code>error[E0277]: `Cell&lt;()&gt;` cannot be shared between threads safely
 --&gt; src/main.rs:4:5
  |
1 | fn foo&lt;T: Send + Copy&gt;() {}
  |           ---- required by this bound in `foo`
...
4 |     foo::&lt;&amp;std::cell::Cell&lt;()&gt;&gt;();
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Cell&lt;()&gt;` cannot be shared between threads safely
  |
  = help: the trait `Sync` is not implemented for `Cell&lt;()&gt;`
  = note: required because of the requirements on the impl of `Send` for `&amp;Cell&lt;()&gt;`
</code></pre></div>



<a name="248384916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Copy%20type%20that%20is%20not%20Send/near/248384916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Copy.20type.20that.20is.20not.20Send.html#248384916">(Aug 04 2021 at 17:58)</a>:</h4>
<p>if you dislike non-Send pointers just wait till you notice that pointers don't impl Default.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>